<template>

  <div class="box_yj" ref="parent" style="position:relative">
    <span></span>    
    <div class="sq-title">人口年龄组成结构</div>

     <div id="charts" ref="charts" :style="chartsDom" v-show="jz"></div>
    <!-- <div class="container_jz" :style="chartsDom" v-if="!jz">
              <div class="circle_jz"></div>
              <div class="circle_jz"></div>
              <div class="circle_jz"></div>
            </div> -->
  </div>
</template>
<script>
export default {
  data () {
    return {
      chartData: [],
      jz:true
    }
  },
  props: ['height','dateProp'],
  computed: {
    chartsDom() {
      return {
        width: (document.documentElement.clientWidth-30)/4-15 - 10+ 'px',
        height: this.height - 30 - 10 + 'px',
        'z-index': 100,
        position: 'relative'
      }
    }
  },
  mounted() {
    this.$nextTick(_=>{
      this.init();
    });
  },
  methods: {
    init() {
       this.chartsInit();
    },
    chartsInit() {
      let option = {

        legend: {
          top: 0,
          textStyle: {
            color: 'rgba(255, 255, 255, 1)'
          }
        },

        tooltip: {
            show: true,
            trigger: 'item',
            formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        color: ['#4c7ef0','#b86cc6','#ff7899','#7fe5ff','#fed866','#5eca41','#5eca41','#16c88b'],
        series: [
            {
                name: '访问来源',
                type: 'pie',
                radius: '55%',
                center: ['50%', '50%'],
                data: [{name:'0-15周岁',value:123},{name:'15-59周岁',value:53},{name:'60周岁以上',value:155}],
                roseType: 'radius',
                label: {
                    color: 'rgba(255, 255, 255, 1)',
                    formatter: (params) => {
                      return params.data.name
                    }
                },
                labelLine: {
                    lineStyle: {
                        color: 'rgba(255, 255, 255, 1)'
                    },
                    smooth: 0.2,
                    length: 10,
                    length2: 20
                },
                itemStyle: {
                    shadowBlur: 200,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                },

                animationType: 'scale',
                animationEasing: 'elasticOut',
                animationDelay: function (idx) {
                    return Math.random() * 200;
                }
            }
        ]
      };
      let chart = this.$echarts.init(this.$refs.charts);
      chart.setOption(option);
    }
  },
}
</script>
<style lang="stylus" scoped>
  .section
    width 100%
    height 100%
</style>